#include<iostream>
using namespace std;
int main(){
    char ch;
    string s;
    getline(cin,s);
    cin>>ch;
    int count = 0;
    for(int i = 0;i<s.length();i++){
        if(s[i]>='A'&&s[i]<='Z'){
            if(s[i]==ch||s[i]+32==ch)
                count++;
        }
        else if(s[i]>='a'&&s[i]<='z'){
            if(s[i]==ch||s[i]-32==ch)
                count++;
        }
        else if(s[i]==ch)
            count++;
    }
    cout<<count;
    return 0;
}

